package com.example.demo.mapper.entity;

import lombok.Data;

import javax.persistence.Table;
import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@Table(name = "sys_user_view")
public class SysUserView {
    private int userId;
    private String number;
    private String name;
    private String avatar;
    private String phone;
    private String email;
    private String password;
    private String schoolId;
    private int state;
    private String createTime;
    private int roleId;
    private String remark;
    private String createBy;
    private boolean isRemeber;

    public boolean getIsRemeber() {
        return isRemeber;
    }

    public void setNumber(int roleId) {
        // 生成随机数
        int randomNumber = (int) ((Math.random() * 100000000) + 1);
        // 获取当前时间作为前缀
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String datePrefix = sdf.format(new Date());
        // 拼接用户编号
        number = String.valueOf(roleId) + datePrefix + String.format("%07d", randomNumber);
    }
}
